package org.languageguide.media;


public class Mobile5MediaGenerator implements MediaGenerator {
	
	public static final String irJavascript = "<script language=\"JavaScript\" src=\"/applets/irmobilehtml5.js\"></script>\n<link href=\"/applets/mobile.css\" rel=\"stylesheet\" type=\"text/css\" />";
	public static final String ir2Javascript = "<script language=\"JavaScript\" src=\"/applets/ir2mobilehtml5.js\"></script>\n<link href=\"/applets/mobile.css\" rel=\"stylesheet\" type=\"text/css\" />";	
	public static final String ipJavascript = "<script language=\"JavaScript\" src=\"/applets/ipmobilehtml5.js\"></script>\n<link href=\"/applets/mobile.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
	public static final String ip2Javascript = "<script language=\"JavaScript\" src=\"/applets/ip2mobilehtml5.js\"></script>\n<link href=\"/applets/mobile.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
	public static final String alphaJavascript = "<script language=\"JavaScript\" src=\"/applets/alphahtml5.js\"></script>\n";
	public static final String alpha2Javascript = "<script language=\"JavaScript\" src=\"/applets/alpha2mobilehtml5.js\"></script><link href=\"/applets/mobile.css\" rel=\"stylesheet\" type=\"text/css\" />\n\n";
	
	/*public static String[] generate(String language, String name, boolean premium){
		String[] media = new String[2];
		return media;
	}*/
	
	public static String[] get(String soundFile, Config config){
		soundFile = Utility.convertwma(soundFile);
		soundFile = Utility.root_mobil_apple + soundFile;//; + ".m4a";
		String[] media = new String[2];
		media[0] = ipJavascript;
		media[1] = getHTML5Tag(soundFile, true);
		return media;
	}
	
	public String[] getIrTags(String soundFile){
		soundFile = Utility.convertwma(soundFile);
		soundFile = Utility.root2_mobil_apple + soundFile;
		String[] media = new String[2];
		media[0] = irJavascript;
		media[1] = getHTML5Tag(soundFile, true);
		return media;
	}
	
	public String[] getAlpha(String soundFile, int seconds){
		soundFile = Utility.convertwma(soundFile);
		soundFile = Utility.root_mobil_apple + soundFile;
		String[] media = new String[2];
		media[0] = alphaJavascript;
		media[1] = getHTML5Tag(soundFile, false);
		return media;
	}
	
	public String[] getAlpha2(String soundFile, int seconds){
		soundFile = Utility.root_mobil_apple + soundFile + ".m4a";
		String[] media = new String[2];
		media[0] = alpha2Javascript;
		media[1] = getHTML5Tag(soundFile, false) + "<button class=\"centered\" onclick=\"launch()\" id=\"launch_button\">Begin!</button><div id=\"modalPage\"></div>";
		return media;
	}
	
	public static String getHTML5Tag(String soundFile, boolean autostart){
		String autoStartStr; 
		if (autostart){
			autoStartStr = "autoplay=\"true\"";
		}
		else{
			autoStartStr = "";
		}
		String audio = "<audio id=\"player\" " + autoStartStr + " controls=\"true\">" +
		"<source src=\"" + soundFile + "\" type=\"audio/mp4\">" + 
		"</audio>";
		return audio;
	}

	@Override
	public String[] getIpTags(String soundFile) {
		soundFile = Utility.convertwma(soundFile);
		soundFile = Utility.root_mobil_apple + soundFile;// + ".m4a";
		String[] media = new String[2];
		media[0] = ipJavascript;
		media[1] = getHTML5Tag(soundFile,true) + "<button  class=\"centered\" onclick=\"launch()\" id=\"launch_button\">Begin!</button><div id=\"modalPage\"></div>";
		return media;
	}
	// disabled=\"true\"
	
	@Override
	public String[] getIp(String soundFile) {
		soundFile = Utility.root_mobil_apple + soundFile + ".m4a";
		String[] media = new String[2];
		media[0] = ipJavascript;
		media[1] = getHTML5Tag(soundFile,true) + "<button class=\"centered\" onclick=\"launch()\" id=\"launch_button\">Begin!</button><div id=\"modalPage\"></div>";
		return media;
	}
	
	public String[] getIp2(String soundFile) {
		soundFile = Utility.root_mobil_apple + soundFile + ".m4a";
		System.out.println("" + soundFile);
		String[] media = new String[2];
		media[0] = ip2Javascript;
		media[1] = getHTML5Tag(soundFile,true) + "<button class=\"centered\" onclick=\"launch()\" id=\"launch_button\">Begin!</button><div id=\"modalPage\"></div>";
		return media;
	}	

	public String getKey(){
		return "3";
	}

	@Override
	public String[] getIr(String soundFile) {
		soundFile = Utility.convertwma(soundFile);
		soundFile = Utility.root_mobil_apple + soundFile;//; + ".m4a";
		String[] media = new String[2];
		media[0] = irJavascript;
		media[1] = getHTML5Tag(soundFile,true);
		return media;
	}
	
	public String[] getIR2(String soundFile) {
		soundFile = Utility.root_mobil_apple + soundFile + ".m4a";
		String[] media = new String[2];
		media[0] = ir2Javascript;
		media[1] = getHTML5Tag(soundFile,false);
		return media;
	}
	
	public boolean useSvg(){
		return true;
	}

}